<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    密码: <input type="text" name="" id="" value="请输入你的密码">

    <script>
        var pass = document.querySelector('input')

        pass.onfocus=function(){
            pass.type="password"
            pass.value=""
        }
        pass.onblur=function(){
            if(pass.value.length==0){
                pass.type="text"
                pass.value="请输入密码"
            }
        }
    </script>
</body>
</html>